package com.yun.zhong.fu.sharecenter.spring_origiond_code_study;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

/**
 * @Author RenPu
 * @Date 2022/10/23 14:53
 * @Version 1.0
 * @Description: spring源码学习： 自定义BeanFactoryPostProcessor
 **/
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {


    /**
     * 在BeanDefinition实例化中，进行修改一些属性信息
     * @param beanFactory
     * @throws BeansException
     */
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        BeanDefinition student = beanFactory.getBeanDefinition("student");
        student.setScope(BeanDefinition.SCOPE_PROTOTYPE);

    }
}
